Signer: Fix loading of per-signature private keys with different types #36
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If a
Signature
object'sKey
orKeyFile
property is set to a non-ref,Signer
assumes it is a file path and attempts to load the private key from it, but it may use the wrong key type, which will cause the signature to fail. CurrentlySigner
looks at$self->{Algorithm}
to determine the key type, and this changes it to look at theSignature
's algorithm instead.I'm not entirely sure this fix is right or necessary because it doesn't really look like a supported use case. The docs for
Signature
say thatKey
should be an object, andKeyFile
is not used at all withinSignature
. So I was also considering just removing the key loading fromSigner
and making it the user's responsibility to load their own keys if they're creating their ownSignature
s. But that would be a backward-incompatible change.Anyway, I'm certainly open to suggestions if you prefer a different fix.